package com.satan.elasticsearch.config;

import com.satan.elasticsearch.constant.HotelMqConsts;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Demon
 * @Date: 2024/2/18 23:57
 * @Description:
 **/
@Configuration
public class AmqpConfig {
    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(HotelMqConsts.HOTEL_EXCHANGE, true, false);
    }
    @Bean
    public Queue insertQueue(){
        return new Queue(HotelMqConsts.HOTEL_INSERT_QUEUE, true);
    }
    @Bean
    public Queue deleteQueue(){
        return new Queue(HotelMqConsts.HOTEL_DELETE_QUEUE, true);
    }
    //绑定交换机
    @Bean
    public Binding insertQueueBinding(){
        return BindingBuilder.bind(insertQueue()).to(topicExchange()).with(HotelMqConsts.HOTEL_INSERT_KEY);
    }
    @Bean
    public Binding deleteQueueBinding(){
        return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with(HotelMqConsts.HOTEL_DELETE_KEY);
    }


}
